import Vue from "vue";
import VueRouter from "vue-router";
import home from "../views/Home";
import about from "../views/About";
import detail from "../views/detail";
import publish from "../views/publish";
import edit from "../views/edit";
import personal from "../views/personal";
Vue.use(VueRouter);

// app.vue是默认启动窗口，home.vue会插进app.vue
const routes = [
  {
    path: "/",
    component: home,
    name: "主页",
    redirect: "/Home",
  },
  {
    path: "/Home",
    component: home,
    name: "主页",
  },
  {
    path: "/about",
    component: about,
    name: "关于",
  },
  {
    path: "/detail/:postsId",
    component: detail,
    name: "详情",
    // component: () => import("../views/detail.vue"),
  },
  {
    path: "/publish",
    component: publish,
    name: "发布",
  },
  {
    path: "/edit/:postsId",
    component: edit,
    name: "编辑",
  },
  {
    path: "/personal",
    component: personal,
    name: "个人中心",
  },

  {
    path: "*",
    component: home,
    name: "主页",
  },
];
const router = new VueRouter({
  mode: "history",
  base: process.env.BASE_URL,
  routes,
});

export default router;
